namespace SMBCFamilyAssessment.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using SMBCFamilyAssessment.Models;
    using System.Collections.Generic;
    using System.Diagnostics;
    internal sealed class Configuration : DbMigrationsConfiguration<SMBCFamilyAssessment.Models.AssessmentContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

       

        protected override void Seed(SMBCFamilyAssessment.Models.AssessmentContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //


            


            try
            {
                List<Family> fList = GetFamilies();
                List<Person> pList = GetPersons();
                List<QuestionSet> qsList = GetQuestionset();
                List<Question> qList = GetQuestions();
                List<AssessmentType> aAssessmentTypeList = GetAssessmentsTypes();
                List<AssessmentSpecification> aAssessmentSpecsList = GetAssessmentspecs();
                List<Assessment> aAssessmentsList = GetAssessments();
                List<AssessmentSession> aAssessmentSessionList = GetAssessmentSessions();


                foreach (Family f in fList)
                {


                    context.Families.Add(f);


                }

                foreach (Person p in pList)
                {


                    context.Persons.Add(p);


                }

                foreach (QuestionSet qs in qsList)
                {


                    context.QuestionSets.Add(qs);


                }

                foreach (Question q in qList)
                {

                    context.Questions.Add(q);


                }



                foreach (AssessmentType aType in aAssessmentTypeList)
                {


                    context.AssessmentTypes.Add(aType);


                }



                foreach (AssessmentSpecification aSpec in aAssessmentSpecsList)
                {


                    context.AssessmentSpecifications.Add(aSpec);


                }

                foreach (Assessment a in aAssessmentsList)
                {


                    context.Assessments.Add(a);



                }


                foreach (AssessmentSession a in aAssessmentSessionList)
                {


                    context.AssessmentSessions.Add(a);



                }

                  context.SaveChanges();


            }

            catch (Exception e)
            {

                Debug.Write(e.Message);

            }








        }
        private List<AssessmentSession> GetAssessmentSessions()
        {

            var sessions = new List<AssessmentSession>
        {

            new AssessmentSession
                {
                    
                    AssessmentSessionId=99,
                    AssessmentId=1,
                    AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=1,
                    QuestionId=1,
                    Score=6,
                    AssessmentSessionDate=DateTime.Now.Date,
                    DateCreated=DateTime.Now,
                
                    
          

                 },
                  new AssessmentSession
                {
                      
                  AssessmentSessionId=100,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=1,
                    QuestionId=2,
                    Score=8,
                    AssessmentSessionDate=DateTime.Now.Date,
                    DateCreated=DateTime.Now,
            

                 },
                  new AssessmentSession
                {
                    AssessmentSessionId=101,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=1,
                    QuestionId=3,
                    Score=4,
                    AssessmentSessionDate=DateTime.Now.Date,
                    DateCreated=DateTime.Now,
                
            
                    

                 },


                 new AssessmentSession
                {
                    
                AssessmentSessionId=102,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=2,
                    QuestionId=4,
                    Score=2,
                    AssessmentSessionDate=DateTime.Now.Date,
                    DateCreated=DateTime.Now,
                
                 },
                  new AssessmentSession
                {
                  AssessmentSessionId=103,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=2,
                    QuestionId=5,
                    Score=1,

                    AssessmentSessionDate=DateTime.Now.Date,
                    DateCreated=DateTime.Now,
                    
            

                 },
                  new AssessmentSession
                {
                 AssessmentSessionId=104,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=2,
                    QuestionId=6,
                    Score=5,

                    AssessmentSessionDate=DateTime.Now.Date,
                    DateCreated=DateTime.Now,
                
            
                    

                 },


                   new AssessmentSession
                {
                 AssessmentSessionId=105,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=3,
                    QuestionId=7,
                    Score=5,

                    AssessmentSessionDate=DateTime.Now.Date,
                    DateCreated=DateTime.Now,
                
            
                    

                 },  new AssessmentSession
                {
                 AssessmentSessionId=106,
                    AssessmentId=1,
                    AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=3,
                    QuestionId=8,
                    Score=5,

                    AssessmentSessionDate=DateTime.Now.Date,
                    DateCreated=DateTime.Now,
                
            
                    

                 },  new AssessmentSession
                {
                   AssessmentSessionId=107,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=3,
                    QuestionId=9,
                    Score=5,

                    AssessmentSessionDate=DateTime.Now.Date,
                    DateCreated=DateTime.Now,
                
            
                    

                 },


                
                 

///////////////////////////////////////////////////////////////////////////////////////////
 new AssessmentSession
                {
                    
                   AssessmentSessionId=108,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=1,
                    QuestionId=1,
                    Score=3,

                    AssessmentSessionDate=DateTime.Now.Date.AddDays(-15),
                    DateCreated=DateTime.Now,
                
                    
          

                 },
                  new AssessmentSession
                {
                      
                     AssessmentSessionId=109,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=1,
                    QuestionId=2,
                     Score=8,
              AssessmentSessionDate=DateTime.Now.Date.AddDays(-15),
                    DateCreated=DateTime.Now,
            

                 },


                    new AssessmentSession
                {
                      
                  AssessmentSessionId=110,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=1,
                    QuestionId=3,
                     Score=8,
              AssessmentSessionDate=DateTime.Now.Date.AddDays(-15),
                    DateCreated=DateTime.Now,
            

                 },




                  new AssessmentSession
                {
                   AssessmentSessionId=111,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=2,
                    QuestionId=4,
                     Score=7,
                   AssessmentSessionDate=DateTime.Now.Date.AddDays(-15),
                    DateCreated=DateTime.Now,
                
            
                    

                 },


                 new AssessmentSession
                {
                    
                  AssessmentSessionId=112,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=2,
                    QuestionId=5,
                     Score=4,
            AssessmentSessionDate=DateTime.Now.Date.AddDays(-15),
                    DateCreated=DateTime.Now,
                
                    
          

                 },

                    new AssessmentSession
                {
                    
               AssessmentSessionId=113,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=2,
                    QuestionId=6,
                     Score=4,
            AssessmentSessionDate=DateTime.Now.Date.AddDays(-15),
                    DateCreated=DateTime.Now,
                
                    
          

                 },




                  new AssessmentSession
                {
                    AssessmentSessionId=114,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=3,
                    QuestionId=7,
                     Score=3,
             AssessmentSessionDate=DateTime.Now.Date.AddDays(-15),
                    DateCreated=DateTime.Now,
                
            

                 },
                  new AssessmentSession
                {
                 AssessmentSessionId=115,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=3,
                    QuestionId=8,
                     Score=10,
         AssessmentSessionDate=DateTime.Now.Date.AddDays(-15),
                    DateCreated=DateTime.Now,
                
            
                    

                 },


                     new AssessmentSession
                {
                 AssessmentSessionId=116,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=3,
                    QuestionId=9,
                     Score=10,
         AssessmentSessionDate=DateTime.Now.Date.AddDays(-15),
                    DateCreated=DateTime.Now,
                
            
                    

                 },



  //////////////////////////////////////////////////////////////////////////////////////////////



   new AssessmentSession
                {
                    
                  AssessmentSessionId=117,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=1,
                    QuestionId=1,
                      Score=10,
         AssessmentSessionDate=DateTime.Now.Date.AddDays(-30),
                    DateCreated=DateTime.Now,
                
                    
          

                 },
                  new AssessmentSession
                {
                      
           AssessmentSessionId=118,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=1,
                    QuestionId=2,
                      Score=9,
                     AssessmentSessionDate=DateTime.Now.Date.AddDays(-30),
                    DateCreated=DateTime.Now,
            

                 },

                    new AssessmentSession
                {
                      
                AssessmentSessionId=119,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=1,
                    QuestionId=3,
                      Score=9,
                     AssessmentSessionDate=DateTime.Now.Date.AddDays(-30),
                    DateCreated=DateTime.Now,
            

                 },



                  new AssessmentSession
                {
                 AssessmentSessionId=120,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=2,
                    QuestionId=4,
                      Score=6,
              AssessmentSessionDate=DateTime.Now.Date.AddDays(-30),
                    DateCreated=DateTime.Now,
                
            
                    

                 },


                 new AssessmentSession
                {
                    
                AssessmentSessionId=121,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=2,
                    QuestionId=5,
                      Score=1,
               AssessmentSessionDate=DateTime.Now.Date.AddDays(-30),
                    DateCreated=DateTime.Now,
                
                    
          

                 },


                 new AssessmentSession
                  {
                    
                  AssessmentSessionId=122,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=2,
                    QuestionId=6,
                      Score=1,
               AssessmentSessionDate=DateTime.Now.Date.AddDays(-30),
                    DateCreated=DateTime.Now,
                
                    
          

                 },


                  new AssessmentSession
                {
                  AssessmentSessionId=123,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=3,
                    QuestionId=7,
                      Score=4,
         AssessmentSessionDate=DateTime.Now.Date.AddDays(-30),
                    DateCreated=DateTime.Now,
                
            

                 },
                  new AssessmentSession
                {
                 AssessmentSessionId=124,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=3,
                    QuestionId=8,
                      Score=7,
         AssessmentSessionDate=DateTime.Now.Date.AddDays(-30),
                    DateCreated=DateTime.Now,

                 },

           new AssessmentSession
                {
                 AssessmentSessionId=125,
                    AssessmentId=1,
                          AssessmentTypeId=1,
                    PersonId=1,
                    QuestionSetId=3,
                    QuestionId=9,
                      Score=7,
         AssessmentSessionDate=DateTime.Now.Date.AddDays(-30),
                    DateCreated=DateTime.Now,

                 },   
              };

            return sessions;

        }
        private List<Assessment> GetAssessments()
        {




            var Assessments = new List<Assessment>
        {

            new Assessment
                {
                    
                    AssessmentId=1,
                    AssessmentTypeId=1,
                    PersonId=1,
                    AssessmentDate=DateTime.Now.Date.Date,
                    DateCreated=DateTime.Now,
                
                    
          

                 },
                  new Assessment
                {
                     AssessmentId=1,
                    AssessmentTypeId=1,
                    PersonId=1,
                    AssessmentDate=DateTime.Now.AddDays(-30).Date,
                    DateCreated=DateTime.Now,
                
            

                 },
                  new Assessment
                {
                    AssessmentId=1,
                    AssessmentTypeId=1,
                    PersonId=1,
                    AssessmentDate=DateTime.Now.AddDays(-15).Date,
                    DateCreated=DateTime.Now,
                
            
                    

                 },

              };

            return Assessments;

        }
        private List<AssessmentSpecification> GetAssessmentspecs()
        {

            var AssessmentSpecs = new List<AssessmentSpecification>
        {

            new AssessmentSpecification
                {
                    
              AssessmentSpecificationId=1,
              AssessmentTypeId=1,
              QuestionSetId=1,
              QuestionSetOrder=1,
              CreatedBy="Admin",
              CreatedDateTime=DateTime.Now,
                    

                 },
                  new AssessmentSpecification
                {
                    
              AssessmentSpecificationId=1,
              AssessmentTypeId=1,
              QuestionSetId=2,
              QuestionSetOrder=2,
              CreatedBy="Admin",
              CreatedDateTime=DateTime.Now,
                    

                 },
                  new AssessmentSpecification
                {
                    
              AssessmentSpecificationId=1,
              AssessmentTypeId=1,
              QuestionSetId=3,
              QuestionSetOrder=3,
              CreatedBy="Admin",
              CreatedDateTime=DateTime.Now,
                    

                 },

              };

            return AssessmentSpecs;
        }
        private List<AssessmentType> GetAssessmentsTypes()
        {

            var AssessmentTypes = new List<AssessmentType>
        {

            new AssessmentType
                {
                    AssessmentTypeId=1,
                    CreatedBy="Admin",
                    Description="Adult",
                    Notes="Adult assessments",
                    CreatedDateTime=DateTime.Now
                    

                 },

                  new AssessmentType
                {
                    AssessmentTypeId=2,
                    CreatedBy="Admin",
                    Description="Child",
                    Notes="Children assessments",
                    CreatedDateTime=DateTime.Now
                    

                 },

              };

            return AssessmentTypes;
        }
        private List<Question> GetQuestions()
        {
            var Questions = new List<Question>{

                    new Question
                    {
                        QuestionId=1,
                        QuestionSetId=1,
                        QuestionDescription="I feel my neighbourhood is a safe place ",
                        CreatedBy="Admin",

                        CreatedDateTime=DateTime.Now

                    },
                     new Question
                    {
                     QuestionId=2,
                        QuestionSetId=1,

                        QuestionDescription="I like to stay home",
                        CreatedBy="Admin",

                        CreatedDateTime=DateTime.Now

                    },


                        new Question
                    {
                   QuestionId=3,
                        QuestionSetId=1,

                        QuestionDescription="I have anti social behaviour problem",
                        CreatedBy="Admin"  ,

                        CreatedDateTime=DateTime.Now              },
                     new Question
                    {
                        QuestionId=4,
                        QuestionSetId=2,
                        QuestionDescription="I am prepared to undertake training",
                        CreatedBy="Admin",

                        CreatedDateTime=DateTime.Now

                    },

                        new Question
                    {
                        QuestionId=5,
                        QuestionSetId=2,
                        QuestionDescription="I like to study further",
                        CreatedBy="Admin",

                        CreatedDateTime=DateTime.Now

                    },
                     new Question
                    {
                        QuestionId=6,
                        QuestionSetId=2,
                        QuestionDescription="I like to stay busy",
                        CreatedBy="Admin",

                        CreatedDateTime=DateTime.Now

                    },

                              new Question
                    {
                        QuestionId=7,
                        QuestionSetId=3,
                        QuestionDescription="Hygine is important to me",
                        CreatedBy="Admin",

                        CreatedDateTime=DateTime.Now

                    },

                              new Question
                    {
                        QuestionId=8,
                        QuestionSetId=3,
                        QuestionDescription="I like home food",
                        CreatedBy="Admin",

                        CreatedDateTime=DateTime.Now

                    },

                              new Question
                    {
                        QuestionId=9,
                        QuestionSetId=3,
                        QuestionDescription="Excercise is important for health",
                        CreatedBy="Admin",

                        CreatedDateTime=DateTime.Now

                    },










                };

            return Questions;
        }
        private List<QuestionSet> GetQuestionset()
        {
            var Questionsets = new List<QuestionSet>{
                   new QuestionSet
                   {


                     QuestionSetId=1,
                       CreatedBy="Admin",
                       CreatedDateTime=DateTime.Now,
                       QuestionSetDescription="Community",
                       LastModifiedBy="Admin"



                   },
                   new QuestionSet
                   {

                       QuestionSetId=2,
                       CreatedBy="Admin",
                       CreatedDateTime=DateTime.Now,
                       QuestionSetDescription="Employment",
                       LastModifiedBy="Admin"
                   },
                   new QuestionSet
                   {

                       QuestionSetId=3,
                       CreatedBy="Admin",
                       CreatedDateTime=DateTime.Now,
                       QuestionSetDescription="Health",
                       LastModifiedBy="Admin"
                   },


               };
            return Questionsets;
        }
        private List<Person> GetPersons()
        {
           var Persons = new List<Person>{
                new Person
                {
                    PersonId=1,
                    FamilyId=1,
                    FirstName="James",
                    LastName="Bond",
                    DOB=new DateTime(1969,2,2,0,0,0),
                     CreatedBy="Admin",
                    CreatedDateTime=DateTime.Now
                    
                 
                },

                     new Person
                {
                    PersonId=2,
                     FamilyId=1,
                    FirstName="Angelina",
                    LastName="Julie",
                    DOB=new DateTime(1979,3,12,0,0,0),
                    
                  CreatedBy="Admin",
                    CreatedDateTime=DateTime.Now
                },

                    new Person
                {
                    PersonId=3,
                     FamilyId=2,
                    FirstName="Brian",
                    LastName="Lara",
                    DOB=new DateTime(1989,4,12,0,0,0),
                     CreatedBy="Admin",
                    CreatedDateTime=DateTime.Now
                 
                },

                     new Person
                {
                    PersonId=4,
                     FamilyId=2,
                    FirstName="Wasim",
                    LastName="Akram",
                    DOB=new DateTime(1968,5,21,0,0,0) ,
                     CreatedBy="Admin",
                    CreatedDateTime=DateTime.Now
                },

                      new Person
                {
                    PersonId=5,
                    FamilyId=3,
                    FirstName="Bill",
                    LastName="Gates",
                    DOB=new DateTime(1958,6,22,0,0,0),
                     CreatedBy="Admin",
                    CreatedDateTime=DateTime.Now
                    
                 
                },

                            new Person
                {
                    PersonId=6,
                  FamilyId=3,
                    FirstName="George",
                   LastName="Oshbourne",
                    DOB=new DateTime(1974,8,1,0,0,0),
                     CreatedBy="Admin",
                    CreatedDateTime=DateTime.Now
                    
                 
                },


             
            };
           return Persons;
        }
        private List<Family> GetFamilies()
        {
            var Families = new List<Family>{
                    new Family
                    {
                        FamilyId=1,
                        Address1="Council House",
                        Address2="Manor Square",
                        PostCode="B91 3QS",
                        Town="Solihull",
                        PrimaryPhoneNumber="01217046000",
                        CreatedBy="Admin",
                        CreatedDateTime=DateTime.Now
                        

                    },

                    new Family
                    {
                        FamilyId=2,
                        Address1="xxxx",
                        Address2="yyyy",
                        PostCode="B91 3QS",
                        Town="Solihull",
                        PrimaryPhoneNumber="01217046000",
                         CreatedBy="Admin",
                        CreatedDateTime=DateTime.Now
                    },
                    new Family
                    {
                        FamilyId=3,
                        Address1="aaaaa",
                        Address2="bbbbb",
                        PostCode="B91 3QS",
                        Town="Solihull",
                        PrimaryPhoneNumber="01217046000",
                      CreatedBy="Admin",
                        CreatedDateTime=DateTime.Now
                    },

                };
            return Families;
        }
    }
}
